package com.song.shop.mongodb;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Song Yinghui
 * @date 2019/8/21
 * @Version 1.0
 */
@RestController
@RequestMapping(value = "/mongo")
public class mongodb {

    @Autowired
    private MongoTemplate mongoTemplate ;

    @RequestMapping(value = "/test")
    public String test(){
        for (int i = 0 ; i < 1000 ; i ++){
            Product product = new Product();
            product.setId(i);
            product.setPeoductName("产品"+i+"号");
            product.setPrice(Double.valueOf(i));
            mongoTemplate.insert(product);
        }

        return "ok";
    }

}
